import axios from './axios';
import { Plane, PlaneTrip } from '../types/plane.type';

export const addPlane = (plane: Plane): Promise<Plane> => {
    return axios({
        method: "POST",
        url: '/api/add/plane',
        data: plane
    })
}

export const getAllPlane = (): Promise<Plane[]> => {
    return axios({
        method: "GET",
        url: '/api/get/all/plane',
    })
}

export const getTripsByPlaneId = (id: number): Promise<PlaneTrip[]> => {
    return axios({
        method: "GET",
        url: `/api/get/planeTripsById?planeId=${id}`,
    })
}

export const addTrip = (trip: PlaneTrip): Promise<PlaneTrip> => {
    return axios({
        method: "POST",
        url: '/api/add/trip',
        data: trip
    })
}

export const getAllPlaneTrip = (): Promise<PlaneTrip[]> => {
    return axios({
        method: "GET",
        url: '/api/get/all/planeTrips',
    })
}

export const deleteTrip = (trip: PlaneTrip): Promise<PlaneTrip> => {
    return axios({
        method: "POST",
        url: '/api/post/delete/planeTrip',
        data: trip
    })
}


export const deletePlane = (plane: Plane): Promise<Plane> => {
    return axios({
        method: "POST",
        url: '/api/post/delete/plane',
        data: plane
    })
}

